//
//  TestViewController.m
//  BCProjectB
//
//  Created by lanou3g on 15/12/21.
//  Copyright © 2015年 lanou3g. All rights reserved.
//

#import "TestViewController.h"
#import "ReadingViewController.h"
#import"MainViewController.h"

@interface TestViewController ()<MainViewControllerDelegate>
@property(nonatomic,assign)BOOL isOpen;
@property(nonatomic,strong)NSMutableArray *ViewControllerArray;
@end

@implementation TestViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor=[UIColor purpleColor];
    self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc]initWithTitle:@"主菜单" style:(UIBarButtonItemStyleDone) target:self action:@selector(rightAction:)];
    _isOpen=YES;
   
    
}
-(void)PassIndex:(NSInteger)indexFor ViewController:(UIViewController *)VC{
    
    ReadingViewController *reading=[[ReadingViewController alloc]init];
    UIViewController *tempViewController=[[UIViewController alloc]init];
    tempViewController.view.backgroundColor=[UIColor redColor];
    UIViewController *tempController=[[UIViewController alloc]init];
    tempController.view.backgroundColor=[UIColor cyanColor];
    if (self.childViewControllers) {
        
    }
    [self.ViewControllerArray addObject:reading];
    [self.ViewControllerArray addObject:tempController];
    [self.ViewControllerArray addObject:tempViewController];
    UIViewController *controller=_ViewControllerArray[indexFor];
    [self addChildViewController:controller];
    [self.view addSubview:controller.view];
}
-(NSMutableArray *)ViewControllerArray{
    if (!_ViewControllerArray) {
        _ViewControllerArray=[NSMutableArray array];
    }
    return _ViewControllerArray;
}

-(void)rightAction:(UIBarButtonItem *)sender{
    if (_isOpen) {
        [UIView animateWithDuration:0.25 animations:^{
            self.navigationController.view.frame=CGRectMake(300, 0, self.view.width, self.view.height);
        } completion:^(BOOL finished) {
            _isOpen=NO;
            self.navigationItem.leftBarButtonItem.title=@"返回";
        }];
 
    }else{
       [ UIView animateWithDuration:0.25 animations:^{
            self.navigationController.view.frame=CGRectMake(0, 0, self.view.width, self.view.height);
        } completion:^(BOOL finished) {
            _isOpen=YES;
            self.navigationItem.leftBarButtonItem.title=@"主菜单";
        }];
    }
  }

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
